<template>
  <div class="app-container" style="margin-top: -30px">
    <h3>当日订单展示</h3>
    <el-table
      v-loading="loading"
      :data="postList"
      :model="queryParams"
      border
      style="font-size: 15px; margin-top: -20px"
      :header-cell-style="{ background: '#6eaef5', color: '#ffffff' }"
    >
      <el-table-column label="序号" align="center" prop="flowid" width="50" />
      <el-table-column label="wdr号" align="center" prop="wdr" width="100" />
      <el-table-column label="投产车间" align="center" prop="productWorkshop" />
      <el-table-column label="订单编号" align="center" prop="orderNo" />
      <el-table-column label="零件号" align="center" prop="partNo" />
      <el-table-column label="订单描述" align="center" prop="orderDescribe" />
      <el-table-column label="订单数量(个)" align="center" prop="orderNum" />
      <el-table-column label="订单状态" align="center" prop="orderState" />
      <el-table-column label="合格率" align="center" prop="yield" />
      <el-table-column
        label="订单录入时间"
        align="center"
        prop="startTime"
        width="260"
      />
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { ordertoday } from "@/api/system/from";
import {orderP} from '@/api/system/order.js'

export default {
  data() {
    return {
      loading: true,
      postList: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        flowid: null,
        wdr: null,
        productWorkshop: null,
        orderNo: null,
        partNo: null,
        orderDescribe: null,
        orderNum: null,
        orderState: null,
        yield: null,
        startTime: null,
      },
      // 表单参数
      // queryParams: {},
      total: 0,
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      // ordertoday(this.queryParams).then((response) => {
      orderP().then((response) => {

        this.postList = response.rows;
        this.total = response.total;
        this.loading = false;
        response.rows.map((item) => {
          if (item.orderNo !== null) {
            // indexOf字符串是否为*
            if (item.orderNo.indexOf("*") !== -1) {
              item.orderNo = item.orderNo.replace(/\*/g, "\n");
            }
            if (item.orderNo.indexOf(".") !== -1) {
              item.orderNo = item.orderNo.replace(/\./g, "\n");
            }
          }
          if (item.partNo !== null) {
            // indexOf字符串是否为*
            if (item.partNo.indexOf("*") !== -1) {
              item.partNo = item.partNo.replace(/\*/g, "\n");
            }
            if (item.orderNo.indexOf(".") !== -1) {
              item.orderNo = item.orderNo.replace(/\./g, "\n");
            }
          }
        });
      });
    },
  },
};
</script>

<style scoped>
h3 {
  text-align: center;
  font-size: 33px;
  color: #6280c6;
}
.app-container >>> .el-table .cell {
  white-space: pre-wrap;
}
</style>
